package addon.w3.mdx.com;

import java.io.IOException;
import java.util.Vector;

import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
 * GEOS						// [Geoset]
	long	nbytes;
	struct {
		long	nbytes;
		VRTX
		NRMS
		PTYP
		PCNT
		PVTX
		GNDX
		MTGC
		MATS
		long	MaterialID;
		long	SelectionGroup;
		long	Selectable		(0:none;4:Unselectable)
		float	BoundsRadius;
		float	MinExtx, MinExty, MinExtz;
		float	MaxExtx, MaxExty, MaxExtz;
		long 	nanim;
		struct {
			float	BoundsRadius;
			float	MinExtx, MinExty, MinExtz;
			float	MaxExtx, MaxExty, MaxExtz;
		} ganimations[nganim];
		UVAS
		UVBS
	} geosets[ngeos];
 * @author madjk
 *
 */
public class MDXGeoset extends MDXParentCOM {
	int length = -1;
	public Vector geosets = null;
	
	public String getTag() {
		return "GEOS";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		geosets = new Vector();
		while(true) {
			byte temp[] = new byte[8];
			ins.read(temp);
			ins.unread(temp);
			String layTag = new String(temp,4,4);
			if(layTag.equals("VRTX")) {
				MDXGeosetCOM mdcom = new MDXGeosetCOM();
				mdcom.decode(ins);
				geosets.add(mdcom);
			} else {
				break;
			}
		}
		//debug( geosets.get( (geosets.size()-1) ).toString() );
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tELEN : "+length);
		if(geosets != null && geosets.size() > 0) sb.append("\n\tGEOSETS : "+geosets.size());
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}